<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
	label.error{color:red}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>二级分类页面</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/common.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/ej_class.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/yhzx.css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function showCity(){
		var pid = $("#select option:selected").val();
		getCity(pid);
	}
	function getCity(pid){
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/site/getCity",
			data:{pid:pid},
			success:function(obj){
				$("#select2").empty();
				var city = obj.city;
				for ( var i in city) {
					$("#select2").append("<option value='"+city[i].district_id+"'>"+city[i].district+"</option>");
				}
			},
			dataType:"json"
		})
	}
	function showContry(){
		var pid = $("#select2 option:selected").val();
		showContryy(pid);
	}
	function showContryy(pid){
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/site/showContry",
			data:{pid:pid},
			success:function(obj){
				$("#select3").empty();
				var showContry = obj.showContry;
				for ( var i in showContry) {
					$("#select3").append("<option value='"+showContry[i].district_id+"'>"+showContry[i].district+"</option>");
				}
			},
			dataType:"json"
		})
	}
	$(function(){
		$("#form").validate({
			rules:{
				name:{
					required:true,
				},
				email:{
					required:true,
					email:true
				},
				detailed:{
					required:true,
				},
				goodtime:{
					dateISO:true
				},
				phone:{
					required:true,
					digits:true
				}
			},
			messages:{
				name:{
					required:"请输入接货人姓名",
				},
				email:{
					required:"请输入电子邮箱",
					email:"请输入正确的email格式"
				},
				detailed:{
					required:"请输入详细地址",
				},
				goodtime:{
					dateISO:"请输入正确的日期格式"
				},
				phone:{
					required:"请输入手机号码",
					digits:"请输入正确的手机号码格式"
				}
			}
		})
	})
	function insertsite(){
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/site/insertSite",
			data:$("#form").serialize(),
			success:function(obj){
				alert("添加地址成功!");
				location.href="<%=request.getContextPath()%>/site/personalSite?uid=${uid}";
			},
			dataType:"json"
		})
	}
</script>
</head>
<body>
<%@ include file="menu.jsp" %>
<div class="w_980 m">
  <div class="pos fl_l ma_t10"><a href="#">首页</a> > <a href="#">礼品箱包、钟表首饰</a> > <a href="#">时尚男包</a> > BOSSSUNWEN博斯绅威男士横款钱包高档礼盒S9... </div>
  <div class="w_980 fl_l">
	<div class="l_200">
	       <div class="yhzx">
		       	   <h2>个人中心</h2>
		           <ul>
		           	   	<li><a href="<%=request.getContextPath()%>/welcome/yhzx_hyy?uid=${user.uid}">欢迎页</a></li>
                        <li><a href="<%=request.getContextPath()%>/personal/personalmessage?uid=${user.uid}">用户信息</a></li>
                        <li><a href="<%=request.getContextPath()%>/order/personalOrder?uid=${user.uid}">我的订单</a></li>
                        <li class="sel"><a href="<%=request.getContextPath()%>/site/personalSite?uid=${user.uid}">收货地址</a></li>
                        <li><a href="<%=request.getContextPath()%>/collect/personalCollect?uid=${user.uid}">我的收藏</a></li>
                        <li><a href="<%=request.getContextPath()%>/leaveword/personalleave?uid=${user.uid}">我的留言</a></li>
                        <li><a href="<%=request.getContextPath()%>/comment/personalcomment?uid=${user.uid}">我的评论</a></li>                                                                        
                        <li><a href="<%=request.getContextPath()%>/personal/exit">安全退出</a></li>                               
		           </ul>
	       </div>
	</div>  
  	<div class="w_770_bor">
           	  <div class="yhzx_title">收货地址</div>
              <div class="hyy fl_l">
	              <form id="form">
	                <table width="80%" border="0" cellspacing="0" cellpadding="0" class="basic">
                        <tr>
                          <td width="103" class="te_r">配送区域：</td>
                          <td colspan="3"><select name="select" id="select" onchange="showCity()">
                            <option>省/自治区</option>
                            <c:forEach var="u" items="${selectLinkage }">
                            	<option value="${u.district_id }">${u.district }</option>
                            </c:forEach>
                          </select>
                            <select name="select2" id="select2" onchange="showContry()">
                              <option>市/区</option>
                            </select>
                            <select name="select3" id="select3">
                              <option>县/区/乡</option>
                          </select>
                            (必填)</td>
                        </tr>
                        <tr>
                          <td class="te_r">收货人姓名：</td>
                          <td width="246"><input type="hidden" value="${uid }" name="uid" /><input type="text" name="name" id="name" class="inputgray" />
                          (必填)</td>
                          <td width="96" class="te_r">电子邮件地址：</td>
                          <td width="228"><input type="text" name="email" id="email" class="inputgray" />
                          (必填)</td>
                        </tr>
                        <tr>
                          <td class="te_r">详细地址：</td>
                          <td><input type="text" name="detailed" id="detailed" class="inputgray" />
                          (必填)</td>
                          <td class="te_r">邮政编码：</td>
                          <td><input type="text" name="zipcode" id="zipcode" class="inputgray" /></td>
                        </tr>
                        <tr>
                          <td class="te_r">电话：</td>
                          <td><input type="text" name="phone" id="phone" class="inputgray" />
                          (必填)</td>
                          <td class="te_r">手机：</td>
                          <td><input type="text" name="telephone" id="telephone" class="inputgray" /></td>
                        </tr>
                        <tr>
                          <td class="te_r">标志建筑：</td>
                          <td><input type="text" name="landmark" id="landmark" class="inputgray" /></td>
                          <td class="te_r">最佳送货时间：</td>
                          <td><input type="text" name="goodtime" id="goodtime" class="inputgray" onclick="WdatePicker()" /></td>
                        </tr>
                        <tr>
                          <td colspan="4" class="te_m"><input type="button" value="新增收货地址" onclick="insertsite()" class="btn" /></td>
                        </tr>
                      </table>
                   </form>
              </div>
			</div>
  </div>
  <div class="w_980 fl_l ma_t10 te_m">关于我们 | 联系我们 | 人才招聘 | 商家入驻 | 广告服务 | 移动终端 | 友情链接 | 销售联盟 <br />
    北京市公安局海淀分局备案编号：11010233381  京ICP证070的4523号 <br />
    Copyright2004-2011  五金商城 版权所有</div>
  <div class="w_980 fl_l ma_t10">
    <ul class="footerpic">
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_pic_04.gif" width="91" height="31" /></a></li>
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_pic_05.gif" width="91" height="31" /></a></li>
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_pic_06.gif" width="91" height="31" /></a></li>
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_pic_07.gif" width="91" height="31" /></a></li>
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_pic_09.gif" width="91" height="31" /></a></li>
      <li><a href=" "><img src="<%=request.getContextPath() %>/images/footer_cnnic.jpg" width="91" height="31" /></a></li>
    </ul>
  </div>
</div>
</body>
</html>
